home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / ebt / bin / ebtexec.z / ebtexec
Encoding:
Text File  |  1998-10-28  |  2.7 KB  |  138 lines

  1. #! /bin/sh
  2.  
  3. ###############################################################################
  4.  
  5. #
  6. # Save the invocvation name, invocation directory, and command name.
  7. #
  8. invoke=$0
  9.  
  10. invoke_directory=`dirname $invoke`
  11. command=`basename $invoke`
  12.  
  13. #
  14. # Set PWD to current directory.
  15. #
  16. PWD=`pwd`
  17.  
  18. #
  19. # Get current architecture and OS name.
  20. #
  21. case "`uname -s`" in
  22.     AIX)
  23.        architecture="aix"
  24.        ;;
  25.  
  26.     HP-UX)
  27.        architecture="hpuxpa"
  28.        ;;
  29.  
  30.     IRIX)
  31.        architecture="irix5m"
  32.        ;;
  33.  
  34.     IRIX64)
  35.        architecture="irix5m"
  36.        ;;
  37.  
  38.     IRIX32)
  39.        architecture="irix5m"
  40.        ;;
  41.  
  42.     OSF1)
  43.        architecture="decosfa"
  44.        ;;
  45.  
  46.     SunOS)
  47.        OSversion=`uname -r`
  48.        first=`expr "$OSversion" : '\(.\)'`
  49.  
  50.        if [ "$first" = "5" ]; then
  51.      first=`uname -p`
  52.          archletter=`expr "$first" : '\(.\)'`
  53.  
  54.      architecture="sunos5$archletter"
  55.        else
  56.      architecture="sunos4"
  57.        fi
  58.        ;;
  59.  
  60.     UNIX_SV)
  61.        if [ "`uname -m`" = "R4000" ]; then
  62.          architecture="uw2i"
  63.        else
  64.          architecture="ews"
  65.        fi
  66.        ;;
  67.  
  68.     *)
  69.        ;;
  70. esac
  71.  
  72. #
  73. # Get position of first '/' in pathname to determine whether command was run
  74. # with an absolute pathname.
  75. #
  76. first=`expr "$invoke" : '\(.\)'`
  77.  
  78. #
  79. # If command pathname begins with '/' then it's already fully qualified.
  80. #
  81. if [ "$first" = "/" ]; then
  82.   directory=$invoke_directory/../$architecture/bin
  83. #
  84. # Otherwise it must be relative to the current directory.
  85. #
  86. else
  87.   #
  88.   # Don't include $invoke_directory in pathname if it is ".".
  89.   #
  90.   if [ "$invoke_directory" = "." ]; then
  91.     directory=$PWD/../$architecture/bin
  92.   else
  93.     directory=$PWD/$invoke_directory/../$architecture/bin
  94.   fi
  95. fi
  96.  
  97. #
  98. # Make sure we found the command directory.
  99. #
  100. if [ -z "$directory" ]; then
  101.   echo "Can't figure out how to run $invoke.  Please re-run with full pathname." 1>&2
  102.   exit 1
  103. fi
  104.  
  105. #
  106. # Set wd to be the command directory without the architecture suffix (for error messages).
  107. #
  108. wd=`dirname $directory`
  109.  
  110. if [ "$wd" = "." ]; then
  111.   wd=$PWD
  112. fi
  113.  
  114. #
  115. # If there is no directory for the architecture or the command does not exist, inform the user.
  116. #
  117. if [ ! -d $directory ]; then
  118.   echo "Unable to execute the command $command installed in $wd." 1>&2
  119.   echo "No software in this directory has been installed for the $architecture architecture." 1>&2
  120.   exit 1
  121. elif [ ! -f $directory/$command ]; then
  122.   echo "The command $command located in $wd has not been installed for the $architecture architecture." 1>&2
  123.   exit 1
  124. fi
  125.  
  126. if [ "$architecture" = "aix" ]; then
  127.   LIBPATH=$directory/../lib:$LIBPATH
  128.   export LIBPATH
  129. elif [ "$architecture" = "hpuxpa" ]; then
  130.   SHLIB_PATH=$directory/../lib:$SHLIB_PATH
  131.   export SHLIB_PATH
  132. else
  133.   LD_LIBRARY_PATH=$directory/../lib:$LD_LIBRARY_PATH
  134.   export LD_LIBRARY_PATH
  135. fi
  136.  
  137. exec $directory/$command "$@"
  138.